from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.views.generic import DetailView,ListView,FormView
from polls.models import Poll
from polls.forms import ContactForm

urlpatterns = patterns('',
    url(r'^$',
        ListView.as_view(
            queryset = Poll.objects.order_by('pub_date')[:5],
            context_object_name='latest_poll_list',
            template_name ='index.html'
            )),

    url(r'^(?P<pk>\d+)/$',
        DetailView.as_view(
            model = Poll,
            template_name ='detail.html'
        )),
    url(r'^(?P<pk>\d+)/results/$',
        DetailView.as_view(
            model = Poll,
            template_name='results.html'),
            name='poll_results'
        ),
    url(r'^(?P<poll_id>\d+)/vote/$','polls.views.vote'),
    #url(r'^contact/$','polls.views.contact'),
    url(r'^contact/$',
        'polls.views.contactAction',
        FormView.as_view(
            form_class = ContactForm,
            initial = {'subject':'subject','message':'message'},
            template_name = 'contact.html',
            success_url = '/polls/contactAction/'
            ),
        ),
    
    url(r'^index/$','polls.views.contactAction'),
)
